package licode.unisop.single.user.infrastructure.repository.dao;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import licode.unisop.single.user.application.entity.PropsEntity;
import licode.unisop.single.user.application.gateway.PropsDao;
import licode.unisop.single.user.infrastructure.assembler.UniUserSingleAssembler;
import licode.unisop.single.user.infrastructure.repository.mapper.PropsMapper;
import licode.unisop.single.user.infrastructure.repository.po.PropsPO;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.Serializable;

/**
 * uni-user-single
 *
 * @author licode
 * @date 2016-08-27 15:28:34
 */
@Component
public class PropsDaoImpl
        extends ServiceImpl<PropsMapper, PropsPO>
        implements PropsDao {
    @Resource
    private UniUserSingleAssembler uniUserSingleAssembler;

    @Override
    public void add(PropsEntity item) {
        super.save(uniUserSingleAssembler.fromPropsEntity(item));
    }

    @Override
    public void update(PropsEntity item) {
        super.updateById(uniUserSingleAssembler.fromPropsEntity(item));
    }

    @Override
    public void removeWithId(Serializable id) {
        super.removeById(id);
    }

    @Override
    public PropsEntity getWithId(Serializable id) {
        return uniUserSingleAssembler.fromProps(super.getById(id));
    }
}
